//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CEffectPool10.cpp>
///	@path	~/src/graphics/dx10/
///	@date	2008/12/22
///	@desc	.

#include "config/config.h"

#include "graphics/dx10/CEffectPool10.h"
#include "graphics/dx10/CEffect10.h"

namespace xeres {

	IMPL_IOBJECT_CLASS( CEffectPool10 );

	// ctor
	CEffectPool10::CEffectPool10( ID3D10EffectPool * pool )
		: m_pEffectPool( pool )
	{
		// create effect
		m_effect = new CEffect10( m_pEffectPool->AsEffect() , NULL );
	}

	// dtor
	CEffectPool10::~CEffectPool10( void )
	{
		m_effect = NULL;
		if( m_pEffectPool )
		{
			UINT rest = m_pEffectPool->Release();
			if( rest != 0 )
			{
				TRACE_ERROR( _S("CEffectPool10::DTOR: Invalid ID3DXEffectPool reference count.") );
				FATAL_ABORT( _S("Invalid ID3DXEffectPool reference count.") );
			}
		}
	}

	// GetEffectPoolInterface
	IUnknown * CEffectPool10::GetEffectPoolInterface( void )
	{
		return m_pEffectPool;
	}

	RefPass<IEffect> CEffectPool10::GetMasterEffect( void )
	{
		return m_effect;
	}
	
} // namespace xeres
